Repository navigation
fix: strict csv quoting names where it refuses, stays cancellable and drops any whitespace around a quoted field - #202
Merged
Conversation
vaceslav
added a commit
that referenced
this pull request
Nov 27, 2026
🤖 I have created a release *beep* *boop* --- ## [0.9.0](v0.8.3...v0.9.0) (2026-11-27) ### Features * an option to read csv quotes strictly, refusing what the reader would otherwise repair ([#199](#199)) ([3ba2885](3ba2885)) * group rows into outline levels in the xlsx and ods writers ([#203](#203)) ([5b87928](5b87928)), closes [#197](#197) ### Bug Fixes * strict csv quoting names where it refuses, stays cancellable and drops any whitespace around a quoted field ([#202](#202)) ([3d4f26b](3d4f26b)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Slava <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
The follow-ups the two reviews of #199 left open for
CsvQuoteMode.Strict, so that its refusals say where and why, its reads stay cancellable, and its whitespace rule matches the trim.MaxFieldChars. It staysTabularLimitException(limit.exceeded) — a quoted field that long which would have closed later is indistinguishable, and a host answers a limit as an upload too large — but every csv field-limit message now names the row, and in strict mode inside a quoted field it says the quote was never closed within the limit.ArchiveCursor.ReadRowprefixes aTabularFormatExceptionfrom the file inside with the entry's path (data/bad.csv: The csv file is not valid at row 2: …), keeping the code and the original as the inner exception. That holds for any file in a zip or tar, a damaged workbook part included.Quotemay not be whitespace whenQuoteModeisStrict(refused when the cursor opens).format.corruptrather thanformat.truncatedfor a file that ends inside a quoted field is kept and explained in the code: a quote left open is far more often a forgotten one than a clipped upload. That whitespace before an opening quote counts towardsMaxFieldChars(it is held until the quote shows it is not content) is documented and pinned by a test.Fixes #201
Measured
mainmin 3,082 ms, this branch min 3,070 ms (no change); allocations, rows (5,127,969) and repairs (458) identical.main185 ms, this branch 76 ms.Tests
New in
StrictQuoteTests: the limit message, the blanks counted towards the limit, no-break and em spaces around a quoted field, cancellation inside a run of spaces after a closing quote, a refusal with the closing quote on either side of the 64 K read-buffer edge, blanks before an opening quote crossing that edge, and strict reads of a zip and a tar whose bad entry is named.OptionsValidationTestsrefuses a whitespace quote in strict mode. The strict round-trip fuzz pads quoted fields with no-break and em spaces too (20,000 cases run locally). The comment of the linear-time test now gives the measured 24 s.Public API
No new members. Behaviour:
CsvCursorOptionswithQuoteMode = Strictand a whitespaceQuoteis now refused (ArgumentOutOfRangeException), and strict mode drops all whitespace, not only space and tab, around a quoted field.Checklist
dotnet buildanddotnet testpass on net10.0 and net11.0 with zero warnings.ErrorCodesand the guide's error-code table agree.src/.